
$(function() {
    load();
});
function load() {
    $.ajax({
        cache : true,
        type : "POST",
        url : "/goods/tGoodsAllocation/listAllocation",
        data : {shelfId:$("#shelfId").val()},// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var list = data;
            var html = "";
            var html_one = "<tr>";
            var html_two = "<tr>";
            var html_tree = "<tr>";
            var html_four = "<tr>";
            var html_five = "<tr>";
            for(var i=0;i<list.length;i++){
                /**
                 * 货位状态
                 */
                var allocationStatus="";
                if(list[i].allocationStatus=="120001"){
                    allocationStatus="#9AFF9A";
                }if(list[i].allocationStatus=="120004"){
                    allocationStatus="#97FFFF";
                }if(list[i].allocationStatus=="120003"){
                    allocationStatus="#E9967A";
                }if(list[i].allocationStatus=="120002"){
                    allocationStatus="#FFC1C1";
                }
                /**
                 * 货位类型
                 */
                var allocationType="";
                if(list[i].allocationType=="122001"){
                    allocationType="orange";
                }if(list[i].allocationType=="122002"){
                    allocationType="green";
                }if(list[i].allocationType=="122003"){
                    allocationType="blue";
                }if(list[i].allocationType=="122004"){
                    allocationType="red";
                }if(list[i].allocationType=="122005"){
                    allocationType="#BA55D3";
                }if(list[i].allocationType=="122006"){
                    allocationType="#CD919E";
                }

                // console.log(list[i].allocationStatus)

                if(list[i].allocationLine==5){
                    html_one+='<td style="background: '+allocationStatus+';color: '+allocationType+'" onclick="edit('+list[i].allocationId+')">'+list[i].orderNum+'</td>';

                }
                if(list[i].allocationLine==4){
                    html_two+='<td style="background: '+allocationStatus+';color:'+allocationType+' "  onclick="edit('+list[i].allocationId+')">'+list[i].orderNum+'</td>';
                }
                if(list[i].allocationLine==3){
                    html_tree+='<td style="background: '+allocationStatus+';color: '+allocationType+'"  onclick="edit('+list[i].allocationId+')">'+list[i].orderNum+'</td>';

                }
                if(list[i].allocationLine==2){
                    html_four+='<td style="background:'+allocationStatus+' ;color: '+allocationType+'"  onclick="edit('+list[i].allocationId+')">'+list[i].orderNum+'</td>';

                }
                if(list[i].allocationLine==1){
                    html_five+='<td style="background: '+allocationStatus+';color: '+allocationType+'"  onclick="edit('+list[i].allocationId+')">'+list[i].orderNum+'</td>';

                }
            }
            html_one+="</tr>"
            html_two+="</tr>"
            html_tree+="</tr>"
            html_four+="</tr>"
            html_five+="</tr>"
            html=html_one+html_two+html_tree+html_four+html_five;
            $("#allocation").html(html)


        }
    });

}


function edit(id) {
    layer.open({
        type : 2,
        title : '编辑',
        maxmin : true,
        shadeClose : false, // 点击遮罩关闭层
        area : [ '800px', '520px' ],
        content : prefix + '/edit/my/' + id // iframe的url
    });
}

